<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function makeFancyString(s) {
      let a = s.substring(0, 2).split('')
      for (let i of s.substring(2))
        //方法用于连接两个或多个数组
        if (a[a.length - 1].concat(a[a.length - 2]) !== i + i)
          a.push(i)
      return a.join('')
    };
    console.log(makeFancyString("aaabaaaa"));
  </script>
</body>

</html>